package net.chrisrichardson.ec2deployer.applications

import groovy.mock.interceptor.MockFor
import net.chrisrichardson.ec2deployer.cluster.DatabaseTier
import net.chrisrichardson.ec2deployer.cluster.TerracottaTier
import net.chrisrichardson.ec2deployer.core.EC2Server
import net.chrisrichardson.ec2deployer.cluster.ClusterSpec

abstract class AbstractApplicationServerTestCase extends GroovyTestCase {

    MockFor mockFileBasedTemplate
    MockFor mockDatabaseTier
    MockFor mockTerracottaTier
    MockFor mockMySqlServer
    MockFor mockWebApp
    MockFor mockTomcatEC2Server

    protected void setUp() {
        super.setUp(); 
        TomcatServer.counter = 0 // FIXME
        mockMySqlServer = new MockFor(MySqlServer)
        mockDatabaseTier = new MockFor(DatabaseTier);
        mockTerracottaTier = new MockFor(TerracottaTier)
        mockWebApp = new MockFor(WebApp)
        mockTomcatEC2Server = new MockFor(EC2Server)
    }

    def makeClusterSpec() {
        new ClusterSpec().tomcats(1).slaves(1).webApp('target/ptrack', "ptrack").catalinaOptsBuilder({builder, databasePrivateDnsName, slaves ->
            builder.prop("foo", "myPrivateDnsName")
        }).schema("ptrack", ["ptrack": "ptrack"])
    }

}